package main

import (
	"fmt"
	"unsafe"
)

var name string
var age int
var sex string
var hello = 99

// 这种方式用的很多
var (
	ni    = "hao"
	wo    = "haohao"
	dajia = "haohaohao"
)

func main() {

	// 这种写法不能作为全局变量
	world := 100

	name = "tomcat"
	age = 20
	sex = "man"

	fmt.Println(name, age, sex, hello, world)

	fmt.Println(ni, wo, dajia)
	fmt.Println(ni, wo, dajia)
	fmt.Println(ni, wo, dajia)
	fmt.Println(ni, wo, dajia)
	fmt.Println(ni, wo, dajia)

	// 允许值变化, 但必须是同一个类型的
	var i int
	i = 10
	i = 20
	//i = 1.2//这个是不允许的 constant 1.2 truncated to integer
	fmt.Println(i)

	var n = 10
	n = 2
	//n = 1.2//这个是不允许的 constant 1.2 truncated to integer
	fmt.Println(n)

	// 两边同时是字符串 + 号 才代表着拼接字符串
	fmt.Println("abc"+"def"+"ghi", true)

	var k uint16 = 255
	fmt.Println(k)

	var s1 = 1000000000
	fmt.Printf("s1 type = %T\n", s1)

	var s2 int64 = 2000000000
	fmt.Printf("s2 type = %T size = %d", s2, unsafe.Sizeof(s2))

}
